package com.project.service;

import com.project.dao.RecruitInfoMapper;
import com.project.entity.RecruitInfo;
import com.project.service.base.BaseService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by hasee on 2017/4/7.
 */

@Transactional(rollbackFor=Exception.class)
@Service
public class RecruitInfoServiceImpl extends BaseService implements RecruitInfoService {


    private static RecruitInfoMapper recruitInfoMapper=null;
    public void setMapper()
    {
        if(recruitInfoMapper==null)
            recruitInfoMapper = sqlSessionTemplate.getMapper(RecruitInfoMapper.class);//1.获取相关mapper
    }

    @Override
    public int modifyRecruitInfoById(RecruitInfo recruitInfo) {
        setMapper();
        return recruitInfoMapper.updateByPrimaryKeySelective(recruitInfo);
    }


    @Override
    public int add(RecruitInfo recruitInfo) {
        setMapper();
        return recruitInfoMapper.insertSelective(recruitInfo);
    }

    @Override
    public int remove(Integer id) {
        setMapper();
        return recruitInfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<RecruitInfo> findAll() {
        setMapper();
        return recruitInfoMapper.selectAll();
    }


    @Override
    public List<RecruitInfo> findByCondition(RecruitInfo recruitInfo) {
        setMapper();
        return recruitInfoMapper.selectByCondition(recruitInfo);
    }

    @Override
    public RecruitInfo findRecruitInfoById(int id) {
        setMapper();
        return recruitInfoMapper.selectByPrimaryKey(id);
    }
}
